#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define fir first
#define sec second
#define chmin(a,b) (a=min(a,b))
#define chmax(a,b) (a=max(a,b))
#define pb push_back
const int inf=0x3f3f3f3f3f3f3f3f;
int n,m,k,l,v,p[100010];
int lb[1000010],ub[1000010];
pii a[100010];
int di[100010],vi[100010],ai[100010],dp[100010];
//priority_queue<pii>q;
vector<int>id[100010];
int lowerbound(int x)
{
    if(x>l)return m+1;
    return lb[x];
}
int upperbound(int x)
{

    if(x>l)return m+1;
    return ub[x];
}
void solve()
{
    scanf("%lld %lld %lld %lld",&n,&m,&l,&v);
    k=0;
    for(int i=1;i<=n;i++)scanf("%lld %lld %lld",di+i,vi+i,ai+i);
    for(int i=1;i<=m;i++)scanf("%lld",p+i);
    chmin(l,p[m]);
    lb[l+1]=ub[l+1]=m+1;
    for(int i=l;i>=0;i--)
    {
        lb[i]=lb[i+1];
        ub[i]=ub[i+1];
        if(p[lb[i]-1]>=i)lb[i]--;
        if(p[ub[i]-1]>i)ub[i]--;
    }
//    for(int i=1;i<=l;i++)cout<<" "<<i<<" "<<lb[i]<<" "<<ub[i]<<endl;
    for(int i=1;i<=n;i++)
    {
        if(ai[i]==0)
        {
            if(vi[i]<=v)continue;
            // l=lowerbound(p+1,p+m+1,di[i])-p;
            int l=lowerbound(di[i]);
//            int l=lb[di[i]];
            if(l<=m)a[++k]={l,m};
        }
        else if(ai[i]<0)
        {
            if(vi[i]<=v)continue;
            // l=lowerbound(p+1,p+m+1,di[i])-p;
            int l=lowerbound(di[i]);
//            int l=lb[di[i]];
            int v0=vi[i];
            int dv=v0-v;
            int rpos=di[i]+(v0*v0-v*v-1)/(-2*ai[i]);
//            int r=upperbound(p+1,p+m+1,rpos)-p-1;
            int r=upperbound(rpos)-1;
//            cout<<"   "<<i<<" "<<rpos<<" "<<r<<endl;
            if(l<=r)a[++k]={l,r};
        }
        else
        {
            int v0=vi[i];
            if(v0>v)
            {
                // l=lowerbound(p+1,p+m+1,di[i])-p;
                int l=lowerbound(di[i]);
                if(l<=m)a[++k]={l,m};
                continue;
            }
            int lpos=di[i]+(v*v-v0*v0)/(2*ai[i]);
 //           cout<<i<<"  "<<lpos<<endl;
//            int l=upperbound(p+1,p+m+1,lpos)-p
            int l=upperbound(lpos);
            if(l<=m)a[++k]={l,m};
        }
    }
    sort(a+1,a+k+1);
    dp[0]=0;
    a[0]={0,0};
    for(int i=1;i<=m;i++)id[i].clear();
    for(int i=1;i<=k;i++)id[a[i].sec].pb(i);
    /*
    while(!q.empty())q.pop();
    q.push({0,0});
    */
    int lst=0;
//    for(int i=1;i<=k;i++)cout<<i<<" "<<a[i].fir<<" "<<a[i].sec<<endl;
    for(int i=1;i<=m;i++)
    {
        dp[i]=inf;
        /*
        while(!q.empty())
        {
            pii p=q.top();
            if(p.sec<lst)q.pop();
            else break;
        }
        int l=q.top().sec;
        */
        dp[i]=dp[lst]+1;
//        q.push({-dp[i],i});
//        cout<<"  "<<i<<" "<<lst<<" "<<dp[i]<<endl;
        for(auto x:id[i])chmax(lst,a[x].fir);
    }
    int ans=inf;
    for(int i=lst;i<=m;i++)chmin(ans,dp[i]);
    ans=m-ans;
    printf("%lld %lld\n",k,ans);
//    cout<<k<<endl;
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    scanf("%lld",&t);
    while(t--)solve();
    return 0;
}
/*
1
5 5 15 4
0 3 0
12 4 0
1 2 1
5 5 -2
6 4 -4
2 5 8 9 15
*/

//16:30.
